﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using LiveCharts;
using LiveCharts.Wpf;

namespace _34_LiveCharts2
{
    /// <summary>
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public SeriesCollection SeriesCollection { get; set; }
        public Func<double, string> Formatter { get; set; }

        public MainWindow()
        {
            InitializeComponent();

            Random rand = new Random();

            LineSeries[] mylineseries = new LineSeries[10];
            for(int index = 0;index < mylineseries.Length; index++)
            {
                mylineseries[index] = new LineSeries();
            }

            for(int index = 0; index < mylineseries.Length; index++)
            {
                

                mylineseries[index].Title = "night" + (index+1).ToString();
                mylineseries[index].Stroke = System.Windows.Media.Brushes.Blue;
                mylineseries[index].StrokeThickness = 10;
                mylineseries[index].StrokeDashArray = new System.Windows.Media.DoubleCollection { 2 };

                mylineseries[index].LineSmoothness = 1;
                mylineseries[index].Fill = System.Windows.Media.Brushes.LightBlue;
                //mylineseries.PointGeometry = null;

                double[] mynum = new double[7];
                for(int i=0;i<7;i++)
                {
                    mynum[i] = (double)rand.Next(0, 10); 
                }
                
                mylineseries[index].Values = new ChartValues<double>(mynum);

                SeriesCollection.Add(mylineseries[index]);
            }

            mychart.LegendLocation = LegendLocation.Top;
            mychart.Background = System.Windows.Media.Brushes.Gray;

            myaxisx.Separator.StrokeThickness = 10;
            myaxisx.Separator.Stroke = System.Windows.Media.Brushes.Gray;// System.Windows.Media.Brushes.Red;
            myaxisx.Separator.Step = 0.5;
            myaxisx.Title = "Date";
            myaxisx.Position = AxisPosition.RightTop;
            //myaxisx.IsMerged = true;

            myaxisx.LabelsRotation = 45;
            myaxisx.Labels = new[] { "Mon", "Tue", "Wen", "Thu", "Fri", "Sat", "Sun" };

            //mytooltip.BulletSize = 10;
            mytooltip.Background = System.Windows.Media.Brushes.LightCyan;
            mytooltip.SelectionMode = TooltipSelectionMode.OnlySender;
            mytooltip.CornerRadius = new CornerRadius(5);
            mytooltip.BorderBrush = System.Windows.Media.Brushes.Yellow;
            mytooltip.BorderThickness = new Thickness(2);

            Formatter = value => value + "-N";
            //SeriesCollection = new SeriesCollection { mylineseries };
            
            DataContext = this;
        }
    }
}
